package com.movie.ticket.sale.movieinterface.common;

import lombok.Data;

/**
 * @author： Micsal
 * @create-time： 2020.10.12 15:44
 * @version： 1.0
 * @description： 回传信息 model
 */
@Data
public class Result {
    private int errorCode;
    private boolean success;
    private String message;
    private Object data;

    public Result() {
    }

    public Result(int errorCode,boolean success, String message, Object data) {
        this.errorCode=errorCode;
        this.success = success;
        this.message = message;
        this.data = data;
    }

    /**
     * 执行成功的返回信息
     * @param data
     * @return
     */
    public static Result success(Object data){
        return new Result(200,true,"执行成功",data);
    }

    /**
     * 执行失败的返回信息
     * @param message
     * @return
     */
    public static Result fail(int errorCode,String message){
        return new Result(errorCode,false,"异常原因：\n"+message,"执行失败");
    }

    /**
     * 便捷的执行成功返回信息
     * @return
     */
    public static Result success(){
        return success(null);
    }



}
